const express = require('express')


const bodyParser = require('body-parser')


const app = express()
//中间有哪些内容   path   fs    router    body-parser(解析post请求)  midddleLog(中间件)  静态资源

//挂载静态资源 
app.use(express.static('public'))



app.use((req, res, next) => {
    console.log('我是守门员中间件')
    // req.aaa = '你好';
    req.aaa={'dongzuo':'coming','sayhi':'hello node'} //中间件传值
    next()

})



// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: false }))

// parse application/json
app.use(bodyParser.json())



const router = require("./router")



// app.use('/homes',router)
app.use('/', router)













app.listen(3000, () => {
    console.log('3000启动')
})